package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.system.domain.dto.LuntaiTyreInstallRequestDto;
import com.ruoyi.system.domain.dto.LuntaiTyreInstallRequestExcel;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.LuntaiTyreInstallRequest;
import com.ruoyi.system.service.ILuntaiTyreInstallRequestService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 轮胎安装申请Controller
 *
 * @author ruoyi
 * @date 2025-03-13
 */
@RestController
@RequestMapping("/tyreInstallRequest")
public class LuntaiTyreInstallRequestController extends BaseController {
    @Autowired
    private ILuntaiTyreInstallRequestService luntaiTyreInstallRequestService;

    /**
     * 查询轮胎安装申请列表
     */
    @GetMapping("/list")
    public TableDataInfo list(LuntaiTyreInstallRequest luntaiTyreInstallRequest) {
        startPage();
        List<LuntaiTyreInstallRequest> list = luntaiTyreInstallRequestService.selectLuntaiTyreInstallRequestList(luntaiTyreInstallRequest);
        return getDataTable(list);
    }

    @GetMapping("/list2")
    public TableDataInfo list2(LuntaiTyreInstallRequestDto request) {
        startPage();
        List<LuntaiTyreInstallRequestDto> list = luntaiTyreInstallRequestService.selectLuntaiTyreInstallRequestList2(request);
        return getDataTable(list);
    }

    /**
     * 导出轮胎安装申请列表
     */
    @Log(title = "轮胎安装申请", businessType = BusinessType.EXPORT)
    @PostMapping("/exportInstallList")
    public void exportInstallList(HttpServletResponse response, LuntaiTyreInstallRequestDto request) {
        List<LuntaiTyreInstallRequestExcel> list = luntaiTyreInstallRequestService.selectLuntaiTyreInstallRequestList3(request);
        ExcelUtil<LuntaiTyreInstallRequestExcel> util = new ExcelUtil<LuntaiTyreInstallRequestExcel>(LuntaiTyreInstallRequestExcel.class);
        util.exportExcel(response, list, "轮胎安装申请数据");
    }
    /**
     * 导出轮胎安装申请列表
     */
    @Log(title = "轮胎安装申请", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LuntaiTyreInstallRequest luntaiTyreInstallRequest) {
        List<LuntaiTyreInstallRequest> list = luntaiTyreInstallRequestService.selectLuntaiTyreInstallRequestList(luntaiTyreInstallRequest);
        ExcelUtil<LuntaiTyreInstallRequest> util = new ExcelUtil<LuntaiTyreInstallRequest>(LuntaiTyreInstallRequest.class);
        util.exportExcel(response, list, "轮胎安装申请数据");
    }

    /**
     * 获取轮胎安装申请详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return success(luntaiTyreInstallRequestService.selectLuntaiTyreInstallRequestById(id));
    }

    /**
     * 新增轮胎安装申请
     */
    @Log(title = "轮胎安装申请", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody LuntaiTyreInstallRequest luntaiTyreInstallRequest) {
        return toAjax(luntaiTyreInstallRequestService.insertLuntaiTyreInstallRequest(luntaiTyreInstallRequest));
    }

    /**
     * 修改轮胎安装申请
     */
    @Log(title = "轮胎安装申请", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody LuntaiTyreInstallRequest luntaiTyreInstallRequest) {
        return toAjax(luntaiTyreInstallRequestService.updateLuntaiTyreInstallRequest(luntaiTyreInstallRequest));
    }

    /**
     * 删除轮胎安装申请
     */
    @Log(title = "轮胎安装申请", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(luntaiTyreInstallRequestService.deleteLuntaiTyreInstallRequestByIds(ids));
    }
    /**
     * 导出轮胎安装申请列表
     */
    @Log(title = "轮胎安装申请", businessType = BusinessType.EXPORT)
    @PostMapping("/exportInstallList2")
    public void export(HttpServletResponse response) {
        List<LuntaiTyreInstallRequestDto> list = luntaiTyreInstallRequestService.selectLuntaiTyreInstallRequest2();
        ExcelUtil<LuntaiTyreInstallRequestDto> util = new ExcelUtil<LuntaiTyreInstallRequestDto>(LuntaiTyreInstallRequestDto.class);
        util.exportExcel(response, list, "轮胎安装申请数据");
    }
}
